package com.gilgamesh.mall.product.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gilgamesh.mall.product.sql.ImageSql;
import com.gilgamesh.mall.sdk.bean.product.ImageEntity;
import com.gilgamesh.mall.sdk.dto.product.ImageDTO;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import java.util.List;

/**
 * Created by Peiyao.Wang on 2021/1/13
 *
 * @author Peiyao.Wang
 * @date 2021/1/13
 */
@Mapper
public interface ImageDao extends BaseMapper<ImageEntity> {
        @Results(
                id = "imageDTOMap",value = {
                @Result(column = "id" ,jdbcType = JdbcType.BIGINT,javaType = Long.class,property = "id"),
                @Result(column = "sku_code",jdbcType = JdbcType.VARCHAR,javaType = String.class,property = "skuCode"),
                @Result(column = "product_code" ,jdbcType = JdbcType.VARCHAR,javaType = String.class,property = "productCode"),
                @Result(column = "image_uri",jdbcType = JdbcType.VARCHAR,javaType = String.class,property = "imageUri"),
                @Result(column = "rank",jdbcType = JdbcType.TINYINT,javaType =java.lang.Integer.class,property = "rank"),
        }
        )

    @SelectProvider(type = ImageSql.class , method = "listImages")
        List<ImageDTO> listImages(ImageEntity entity);

    @Select("select * from t_image where id =#{id}")
    ImageDTO getById(Long id);

}
